package com.liangwj.springbootrabbitmq.rabbit.onetoone;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.AsyncAmqpTemplate;
import org.springframework.amqp.rabbit.AsyncRabbitTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * <b>Description:</b> RabbitMQ 发送者 <br/>
 * @author Lingwenjun
 * @date 2019/1/4-15:37
 * @version 1.0
 */
@Component
public class HelloSender {

    @Autowired
    //private AmqpTemplate rabbitTemplate; //!!已过时!!rabbitTemplate是springboot 提供的默认实现
    private RabbitTemplate rabbitTemplate; //rabbitTemplate是springboot 提供的默认实现

    private AsyncRabbitTemplate asyncRabbitTemplate;

    public void send() {
        String context = "hello " + new Date();
        System.out.println("Sender:" + context);
        this.rabbitTemplate.convertAndSend("hello", context);
    }
}
